package com.wyy.servlet.web;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @ClassName OutServlet
 * @Description //TODO
 * @Author wky
 * @Date 2021/9/12 16:18
 * @Version 1.0
 **/
@WebServlet(urlPatterns = "/loginOut")
public class OutServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //清除session
        req.getSession().invalidate();
        //跳转页面
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter writer = resp.getWriter();
        writer.println("<script>alert('退出成功！');top.location.href='login.jsp';</script>");
    
    }
}
